package org.ysh.service;

import org.springframework.stereotype.Service;
import org.ysh.domain.RoleResource;
import org.ysh.mapper.BaseMapper;
import org.ysh.mapper.RoleResourceMapper;

@Service
public class RoleResourceService extends BaseService<Integer, RoleResource>{
    public RoleResourceService(RoleResourceMapper baseMapper) {
        super(baseMapper);
    }

    public void saveRoleResource(Integer roleId,Integer[] ids) {
        ((RoleResourceMapper)baseMapper).deleteRoleResource(roleId);
        if(ids != null){
            for(int id: ids){
                RoleResource roleResource = new RoleResource();
                roleResource.setRoleId(roleId);
                roleResource.setResourceId(id);
                baseMapper.insert(roleResource);
            }
        }
    }
}
